package yk;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

import com.walter.domain.Employee;
public class UserRegister {
	private Employee userBean;
	private Connection con;
	public UserRegister() {
 
		try {
			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection("jdbc:mysql:///directroute", "root",
					"root");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void setUserBean(Employee userBean) {
		this.userBean = userBean;
	}

	public void regist() throws Exception {
	
		String sql = "insert into employee(name,sex,card,tele,email,num,password,status)values(?,?,?,?,?,?,?,1)";
		try {
			PreparedStatement pstmt = con.prepareStatement(sql);
			pstmt.setString(1, userBean.getName());
			pstmt.setString(2, userBean.getSex());
			pstmt.setString(3, userBean.getCard());
			pstmt.setString(4, userBean.getTele());
			pstmt.setString(5, userBean.getEmail());
			pstmt.setString(6, "201512210XXXX");
			pstmt.setString(7, "666666");
			
			pstmt.executeUpdate();
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}

	}
}
